<template>
  <div>
    <div class="block">
      <van-swipe class="my-swipe" :autoplay="3000"  indicator-color="white">
        <van-swipe-item v-for="item in banners" :key="item.encodeId" class="svipebgm">
          <img :src="item.imageUrl" alt="banner" class="bannerimg" />
        </van-swipe-item>
      </van-swipe>
    </div>
  </div>
</template>

<script>
import { getBanners } from '../../js/axios'
export default {
  data () {
    return {
      banners: [],
    }
  },
  created () {
    this.getbanners()
  },
  methods: {
    getbanners () {
      var that = this
      getBanners().then( ( res ) => {
        res.data.banners.forEach( ( item, index ) => {
          if ( index <= 3 ) {
            that.banners.push( item )
          }
        } )
        // console.log( that.banners )
      } )
    }
  },
}
</script>

<style lang="less" scoped>
//
.block .bannerimg {
  width: auto;
  height: 3rem;
}
.block {
  margin: 0.3rem 0;
  border-radius: 5px;
  overflow: hidden;
}

.block .my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  height: 3rem;
  background-color: #39a9ed;
}
.svipebgm {
  background-image: url("../../../public/imgs/swipbng.png");
}
</style>>
